//
//  ViewController.m
//  StickerDemo
//
//  Created by jingliang on 2017/5/3.
//  Copyright © 2017年 井良. All rights reserved.
//

#import "ViewController.h"
#import "BoxStickerView.h"

@interface ViewController ()<BoxStickerViewDelegate>
@property (strong, nonatomic) BoxStickerView *selectedSticker;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor=[UIColor grayColor];
    
    UIImage *image1=[UIImage imageNamed:@"syed.png"];

    
    CGRect imageViewFrame = CGRectMake(0, 0,image1.size.width, image1.size.height);
    CGRect contentLabelFrame = CGRectMake(0, 0, 100, image1.size.height);
    BoxStickerView *sticker1 = [[BoxStickerView alloc]initWithFrame:imageViewFrame contentLabelFrame:contentLabelFrame contentImage:image1];
    
    sticker1.center = self.view.center;
    sticker1.enabledBorder = YES;
    sticker1.selected = NO;
    

    sticker1.delegate = self;
    sticker1.tag = 1;
    [self.view addSubview:sticker1];
    
    sticker1.contentLabel.backgroundColor = [UIColor yellowColor];
    sticker1.clipsToBounds = NO;
    
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture)];
    [self.view addGestureRecognizer:tap];
}
-(void)tapGesture
{
    if (self.selectedSticker) {
        self.selectedSticker.selected = NO;
        self.selectedSticker=nil;
    }
}
#pragma mark - StickerViewDelegate
- (void)stickerViewDidTapContentView:(BoxStickerView *)stickerView {
    
    NSLog(@"tap");
    if (self.selectedSticker) {
        self.selectedSticker.selected = NO;
    }
    
    self.selectedSticker = stickerView;
    self.selectedSticker.selected = YES;
}

- (void)stickerViewDidTapDeleteControl:(BoxStickerView *)stickerView {
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
//    
//    UIButton *btn = [[UIButton alloc]init];
//    btn.selected = YES;
    
    
    
}


@end
